
package com.boyuan.aboutcase;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import android.R.integer;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnCancelListener;
import android.content.SharedPreferences.Editor;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.autonavi.amap.mapcore2d.DPoint;
import com.boyuan.huijiaoyu.CaseMemberActivity;
import com.boyuan.huijiaoyu.R;
import com.example.contactfragment.MyGroup;
import com.example.huanxin.GroupDetailActivity;
import com.example.newfragment.CaseListEntity;
import com.example.newfragment.HomeService;
import com.example.newfragment.members;
import com.google.gson.Gson;
import com.magicsoft.app.entity.CaseDetailEntity;
import com.magicsoft.app.helper.ToastHelper;
import com.magicsoft.app.wcf.CaseService;
import com.magicsoft.app.wcf.listener.GetMultilParamsListener;
import com.magicsoft.app.wcf.listener.PostRecordResponseListener;
import com.magicsoft.constant.Constant;

public class CaseDetailActivity extends FragmentActivity implements
		OnClickListener {

	private TextView mTv_dynamic;
	private TextView mTv_aboutcase;
	private TextView mTv_Attachment;
	private TextView mLine_dynamic;
	private TextView mLine_aboutcase;
	private TextView mLine_Attachment;
	private FragmentManager mFragmentManager;
	private DynamicFragment mDynamic_fragment;
	private AboutCaseFragment mAboutcase_fragment;
	private AttachmentFragment mAttachment_fragment;
	private FragmentTransaction fragmentTransaction;
	private ColorStateList color_orange;
	private ColorStateList color_black;
	private PopupWindow mPopupWindow;
	// 屏幕的width
	private int mScreenWidth;
	// 屏幕的height
	private int mScreenHeight;
	// PopupWindow的width
	private int mPopupWindowWidth;
	// PopupWindow的height
	private int mPopupWindowHeight;
	private EditText mEd_case_comments;
	private TextView mTv_title;
	private TextView mTv_title2;
	private TextView mTv_creater;
	private TextView tv_format_create;
	private String groupId;
	private String groupName;
	private RelativeLayout rela_casemore;
	private LinearLayout mMore_case_layout1;
	private TextView tv_desc;
	private HomeService homeService;
	private CaseDetailEntity caseDetailEntity;
	private String tag = "CaseDetailActivity";
	private ScrollView mScrollView;
	private TextView tv_casedetail_status;
	private CaseService caseService;
	private RelativeLayout case_group_details_normal;
	private boolean progressShow;
	private ProgressDialog pd;
	private boolean isShowDownDrop = false;
	private MyGroup mygroup;
	private String type;
	ArrayList<String> membernamelist = new ArrayList<String>();
	public static final String MESSAGE_RECEIVED_ACTION = "com.magicsoft.weitown.fragment.MESSAGE_RECEIVED_ACTION";
	private UploadfileReceiver uploadfileReceiver;
	private String caseid;
//	private CloseactivyReceiver closeactivyReceiver;
	private DeletefileReceiver deletefileReceiver;
	private ChangecaseReceiver changecaseReceiver;
	private ExitcaseReceiver exitcaseReceiver;
	private AddmemberReceiver addmemberReceiver;
	private DelTrendsReceiver delTrendsReceiver;
	boolean isgetcaseok = false;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_case_detail);
		findViewById(R.id.rela_caseDetail).setOnClickListener(this);
		registUploadfile();
		registDeletefile();
		registChangecase();
		registExitcase();
		registAddmember();
		registDelTrends();
		Intent intent = getIntent();
		caseid = intent.getStringExtra("caseid");
		initUI();
//		getCaseDetailInfo();
		getCaseDetailInfo2();
	}
	
	//删除动态后接受广播
	private void registDelTrends(){
		delTrendsReceiver = new DelTrendsReceiver();
		IntentFilter filter = new IntentFilter();
		filter.addAction(Constant.DELTRENDS);
		registerReceiver(delTrendsReceiver, filter);
	}
	
	class DelTrendsReceiver extends BroadcastReceiver{

		@Override
		public void onReceive(Context arg0, Intent arg1) {
			getCaseDetailInfo2();
		}
	}
	
	//添加关注后接收广播
	private void registAddmember(){
		addmemberReceiver = new AddmemberReceiver();
		IntentFilter intentFilter = new IntentFilter();
		intentFilter.addAction(Constant.ADDMENBER);
		registerReceiver(addmemberReceiver, intentFilter);
	}
	
	class AddmemberReceiver extends BroadcastReceiver{

		@Override
		public void onReceive(Context arg0, Intent arg1) {
//			getCaseDetailInfo();
			getCaseDetailInfo2();
		}
	}
	
	//取消关注后接收广播
	private void registExitcase(){
		exitcaseReceiver = new ExitcaseReceiver();
		IntentFilter intentFilter = new IntentFilter();
		intentFilter.addAction(Constant.EXITCASE);
		registerReceiver(exitcaseReceiver, intentFilter);
	}
	
	class ExitcaseReceiver extends BroadcastReceiver{

		@Override
		public void onReceive(Context arg0, Intent arg1) {
//			getCaseDetailInfo();
			finish();
		}
	}
	
	//上传文件后接收广播
	private void registUploadfile(){
		uploadfileReceiver = new UploadfileReceiver();
		IntentFilter filter = new IntentFilter();
		filter.addAction(Constant.UPLOADFILE);
		registerReceiver(uploadfileReceiver, filter);
	}
	
	class UploadfileReceiver extends BroadcastReceiver{

		@Override
		public void onReceive(Context arg0, Intent arg1) {
			getCaseDetailInfo2();
//			getCaseDetailInfo();
		}
	}
	
	//删除文件后接收广播
		private void registDeletefile(){
			deletefileReceiver = new DeletefileReceiver();
			IntentFilter filter = new IntentFilter();
			filter.addAction(Constant.DELFILE);
			registerReceiver(deletefileReceiver, filter);
		}
		
		class DeletefileReceiver extends BroadcastReceiver{

			@Override
			public void onReceive(Context arg0, Intent arg1) {
//				getCaseDetailInfo();
				getCaseDetailInfo2();
			}
		}
	
	//修改case后接收广播
	private void registChangecase() {
		changecaseReceiver = new ChangecaseReceiver();
		IntentFilter filter = new IntentFilter();
		filter.addAction(Constant.CHANGEMYCASE);
		registerReceiver(changecaseReceiver, filter);
	}

	class ChangecaseReceiver extends BroadcastReceiver {
		@Override
		public void onReceive(Context context, Intent intent) {
//			getCaseDetailInfo();
			getCaseDetailInfo2();
		}
	}
	
	private void initUI() {

		progressShow = true;
		pd = new ProgressDialog(this);
		pd.setCanceledOnTouchOutside(false);
		pd.setOnCancelListener(new OnCancelListener() {

			@Override
			public void onCancel(DialogInterface dialog) {
				progressShow = false;
			}
		});
		pd.setMessage(getString(R.string.Is_landing2));
		pd.show();

		// 动态
		findViewById(R.id.rela_dynamic).setOnClickListener(this);
		mTv_dynamic = (TextView) findViewById(R.id.tv_dynamic);
		mLine_dynamic = (TextView) findViewById(R.id.line_dynamic);
		// 相关case
		findViewById(R.id.rela_aboutcase).setOnClickListener(this);
		mTv_aboutcase = (TextView) findViewById(R.id.tv_aboutcase);
		mLine_aboutcase = (TextView) findViewById(R.id.line_aboutcase);
		// 附件
		findViewById(R.id.rela_Attachment).setOnClickListener(this);
		mTv_Attachment = (TextView) findViewById(R.id.tv_Attachment);
		mLine_Attachment = (TextView) findViewById(R.id.line_Attachment);

		rela_casemore = (RelativeLayout) findViewById(R.id.rela_casemore);
		rela_casemore.setOnClickListener(this);

		findViewById(R.id.lin_back).setOnClickListener(this);
		findViewById(R.id.tv_case_comment).setOnClickListener(this);

		mScrollView = (ScrollView) findViewById(R.id.scrollView1);

		mFragmentManager = getSupportFragmentManager();
		mDynamic_fragment = (DynamicFragment) mFragmentManager
				.findFragmentById(R.id.dynamic_fragment);
		mAboutcase_fragment = (AboutCaseFragment) mFragmentManager
				.findFragmentById(R.id.aboutcase_fragment);
		mAttachment_fragment = (AttachmentFragment) mFragmentManager
				.findFragmentById(R.id.Attachment_fragment);
		mEd_case_comments = (EditText) findViewById(R.id.case_comments);

		Resources resources = getResources();
		color_orange = resources.getColorStateList(R.color.orange);
		color_black = resources.getColorStateList(R.color.black);

		mTv_title = (TextView) findViewById(R.id.tv_title);
		mTv_title2 = (TextView) findViewById(R.id.tv_title2);
		mTv_creater = (TextView) findViewById(R.id.tv_creater);
		tv_format_create = (TextView) findViewById(R.id.tv_format_create);
		tv_desc = (TextView) findViewById(R.id.tv_desc);
		tv_casedetail_status = (TextView) findViewById(R.id.tv_casedetail_status);

		case_group_details_normal = (RelativeLayout) findViewById(R.id.lay_case_member);
		case_group_details_normal.setOnClickListener(this);

		if (groupId == null) {
			case_group_details_normal.setVisibility(View.VISIBLE);
		} else {
			case_group_details_normal.setVisibility(View.VISIBLE);
		}

		showDynamicFragment();
	}

	private void showDynamicFragment() {
		fragmentTransaction = mFragmentManager.beginTransaction()
				.hide(mDynamic_fragment).hide(mAboutcase_fragment)
				.hide(mAttachment_fragment);
		fragmentTransaction.show(mDynamic_fragment).commitAllowingStateLoss();
		setSelectedTab(0);
	}

	private void setSelectedTab(int postion) {

		switch (postion) {
		case 0:
			mTv_dynamic.setTextColor(color_orange);
			mTv_aboutcase.setTextColor(color_black);
			mTv_Attachment.setTextColor(color_black);
			mLine_dynamic.setVisibility(View.VISIBLE);
			mLine_aboutcase.setVisibility(View.GONE);
			mLine_Attachment.setVisibility(View.GONE);
			break;
		case 1:
			mTv_dynamic.setTextColor(color_black);
			mTv_aboutcase.setTextColor(color_orange);
			mTv_Attachment.setTextColor(color_black);
			mLine_dynamic.setVisibility(View.GONE);
			mLine_aboutcase.setVisibility(View.VISIBLE);
			mLine_Attachment.setVisibility(View.GONE);
			break;
		case 2:

			mTv_dynamic.setTextColor(color_black);
			mTv_aboutcase.setTextColor(color_black);
			mTv_Attachment.setTextColor(color_orange);
			mLine_dynamic.setVisibility(View.GONE);
			mLine_aboutcase.setVisibility(View.GONE);
			mLine_Attachment.setVisibility(View.VISIBLE);
			break;

		default:
			break;
		}
	}

	@Override
	public void onClick(View v) {
		fragmentTransaction = mFragmentManager.beginTransaction()
				.hide(mDynamic_fragment).hide(mAboutcase_fragment)
				.hide(mAttachment_fragment);
		switch (v.getId()) {
		case R.id.rela_dynamic:
			fragmentTransaction.show(mDynamic_fragment).commit();
			setSelectedTab(0);
			if (null != mPopupWindow) {
				mPopupWindow.dismiss();
				isShowDownDrop = false;
			}
			break;
		case R.id.rela_aboutcase:

			fragmentTransaction.show(mAboutcase_fragment).commit();
			setSelectedTab(1);
			if (null != mPopupWindow) {
				mPopupWindow.dismiss();
				isShowDownDrop = false;
			}
			break;
		case R.id.rela_Attachment:

			fragmentTransaction.show(mAttachment_fragment).commit();
			setSelectedTab(2);
			if (null != mPopupWindow) {
				mPopupWindow.dismiss();
				isShowDownDrop = false;
			}
			break;
		case R.id.rela_casemore:
//			isShowDownDrop = !isShowDownDrop;
//			if (isShowDownDrop) {
//				getPopupWindowInstance();
//				mPopupWindow.showAsDropDown(v);
//			} else {
//				mPopupWindow.dismiss();
//			}
			ChangeCase();
			break;
		case R.id.lin_back:
			finish();
			break;
		case R.id.lay_case_member:
			casejumpgroup_detail();
			break;
//		case R.id.more_case_rela_layout1:
//			ChangeCase();
//			break;
//		case R.id.more_case_rela_layout2:
//			CancelAttentionForCase();
//			break;
//		case R.id.more_case_rela_layout3:
//			AddCaseMembers();
//			break;
		case R.id.tv_case_comment:
			addTrend();
			break;
		case R.id.rela_caseDetail:
			InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
			break;
		default:
			break;
		}
	}

	private void AddCaseMembers() {
		if (null != mPopupWindow) {
			mPopupWindow.dismiss();
			isShowDownDrop = false;
		}
		Intent intent = new Intent();
		if (caseDetailEntity != null) {
			// List<members> memberslist = caseDetailEntity.getMembers();
			// intent.putExtra("members", (Serializable) memberslist);
			intent.putExtra("caseDetailEntity", caseDetailEntity);
		}
		intent.setClass(this, AddCaseMembersActivity.class);
		startActivity(intent);
	}

	private void CancelAttentionForCase() {
		if (caseDetailEntity == null) {
			return;
		}
		if (caseService == null) {
			caseService = new CaseService(CaseDetailActivity.this);
		}
		String case_id = caseDetailEntity.getCid();
		SharedPreferences sp = getSharedPreferences("a.xml", 0);
		String accountId = sp.getString("accountId", "");
		String corp_id = sp.getString("username", "");
		String operator = sp.getString("realname", "");
		caseService.CancelAttention(corp_id, case_id, accountId, operator,
				new PostRecordResponseListener() {
					@Override
					public void onFinish(String succString) {
						Intent intent = new Intent();
						intent.setAction(Constant.NOTITYHOMELIST);
						sendBroadcast(intent);
						Intent intent1 = new Intent();
						intent1.setAction(Constant.NOTITYCASEDETAIL);
						sendBroadcast(intent1);
						ToastHelper.showMsg(CaseDetailActivity.this,
								succString, false);
						finish();
					}

					@Override
					public void onFailed(String failString) {
						ToastHelper.showMsg(CaseDetailActivity.this,
								failString, false);
					}
				});
	}

	private void addTrend() {
		if (null != mPopupWindow) {
			mPopupWindow.dismiss();
			isShowDownDrop = false;
		}
		String comment_text = mEd_case_comments.getText().toString().trim();
		if ("".equals(comment_text)) {
			ToastHelper.showMsg(this, "评论不能为空!", false);
			return;
		}
		if (caseService == null) {
			caseService = new CaseService(this);
		}
		SharedPreferences sp = getSharedPreferences("a.xml", 0);
		String corp_id = sp.getString("username", "");
		String operator = sp.getString("realname", "");
		if (caseDetailEntity != null) {
			String case_id = caseDetailEntity.getCid();
			caseService.addTrends(corp_id, case_id, comment_text, corp_id,
					operator, new PostRecordResponseListener() {
						@Override
						public void onFinish(String succString) {
//							getCaseDetailInfo();
							getCaseDetailInfo2();
							ToastHelper.showMsg(CaseDetailActivity.this,"评论成功", false);
							mEd_case_comments.setText("");
						}

						@Override
						public void onFailed(String failString) {
							ToastHelper.showMsg(CaseDetailActivity.this,
									failString, false);
						}
					});
		} else {
			ToastHelper.showMsg(this, "未加载完毕", false);
		}
	}

	private void ChangeCase() {
		if(caseDetailEntity != null){
			Intent intent = new Intent(CaseDetailActivity.this, NewCaseDetailActivity.class);
			intent.putExtra("groupId", groupId);
			intent.putExtra("caseDetailEntity", caseDetailEntity);
			intent.putExtra("CaseTitle", "修改case");
			startActivityForResult(intent, Constant.ChangeCaseDetail_Code);
		}
//		if (caseDetailEntity != null) {
//			if (null != mPopupWindow) {
//				mPopupWindow.dismiss();
//				isShowDownDrop = false;
//			}
//			Intent intent = new Intent(this, NewCaseDetailActivity.class);
//			intent.putExtra("groupId", groupId);
//			intent.putExtra("caseDetailEntity", caseDetailEntity);
//			intent.putExtra("CaseTitle", "修改case");
//			startActivityForResult(intent, Constant.ChangeCaseDetail_Code);
//		} else {
//			if (null != mPopupWindow) {
//				mPopupWindow.dismiss();
//				isShowDownDrop = false;
//			}
//			ToastHelper.showMsg(this, "未加载完毕", false);
//		}
	}

	private void casejumpgroup_detail() {
		Intent intent = new Intent(this, CaseMemberActivity.class);
		intent.putExtra("caseDetailEntity", caseDetailEntity);
		startActivity(intent);
	}

	/*
	 * 获取PopupWindow实例
	 */
	private void getPopupWindowInstance() {
		if (null != mPopupWindow) {
			mPopupWindow.dismiss();
			return;
		} else {
			initPopuptWindow();
		}
	}

	/*
	 * 创建PopupWindow
	 */
	private void initPopuptWindow() {
		LayoutInflater layoutInflater = LayoutInflater.from(this);
		View popupWindow = layoutInflater.inflate(R.layout.more_case_layout,
				null);
		popupWindow.findViewById(R.id.more_case_rela_layout1)
				.setOnClickListener(this);
		popupWindow.findViewById(R.id.more_case_rela_layout2)
				.setOnClickListener(this);
		popupWindow.findViewById(R.id.more_case_rela_layout3)
				.setOnClickListener(this);
		LinearLayout more_case_layout1 = (LinearLayout) popupWindow
				.findViewById(R.id.more_case_layout1);
		int w = View.MeasureSpec.makeMeasureSpec(0,
				View.MeasureSpec.UNSPECIFIED);
		int h = View.MeasureSpec.makeMeasureSpec(0,
				View.MeasureSpec.UNSPECIFIED);
		more_case_layout1.measure(w, h);
		int measuredHeight = more_case_layout1.getMeasuredHeight();

		// 创建一个PopupWindow
		// 参数1：contentView 指定PopupWindow的内容
		// 参数2：width 指定PopupWindow的width
		// 参数3：height 指定PopupWindow的height

		int width = rela_casemore.getWidth();

		mPopupWindow = new PopupWindow(popupWindow, width, measuredHeight);

		// 获取屏幕和PopupWindow的width和height
		mScreenWidth = getWindowManager().getDefaultDisplay().getWidth();
		mScreenWidth = getWindowManager().getDefaultDisplay().getHeight();
		mPopupWindowWidth = mPopupWindow.getWidth();
		mPopupWindowHeight = mPopupWindow.getHeight();
	}

//	private void getCaseDetailInfo() {
//		if (homeService == null) {
//			homeService = new HomeService(this);
//		}
////		SharedPreferences sp = getSharedPreferences("a.xml", 0);
////		String corp_id = sp.getString("username", "");
//		homeService.GetCaseDetail(caseid, "1",
//				new GetMultilParamsListener() {
//
//					@Override
//					public void onFinish(Object... params) {
//						caseDetailEntity = (CaseDetailEntity) params[0];
//						CaseDetailEntity caseDetailEntity1 = (CaseDetailEntity) params[0];
//						membernamelist.clear();
//						for (int i = 0; i < caseDetailEntity.getMembers().size(); i++) {
//							membernamelist.add(caseDetailEntity.getMembers().get(i).getName());
//						}
//						// 发送广播更新动态
//						Intent intent = new Intent();
//						intent.setAction(Constant.GETDYNAMIC);
//						intent.putExtra("caseDetailEntity", caseDetailEntity1);
//						sendBroadcast(intent);
//						//发送广播上传更新
//						Intent intent2 = new Intent();
//						intent2.setAction(Constant.GETATTACH);
//						intent2.putExtra("caseDetailEntity", caseDetailEntity1);
//						sendBroadcast(intent2);
//						setData();
//						pd.dismiss();
//					}
//
//					@Override
//					public void onFailed(String Message) {
//						ToastHelper.showMsg(CaseDetailActivity.this, Message,
//								false);
//					}
//				});
//	}
	
	private void getCaseDetailInfo2() {
		if (homeService == null) {
			homeService = new HomeService(this);
		}
		homeService.getCaseAndIm(caseid,
				new GetMultilParamsListener() {

					@Override
					public void onFinish(Object... params) {
						caseDetailEntity = (CaseDetailEntity) params[0];
						CaseDetailEntity caseDetailEntity1 = (CaseDetailEntity) params[0];
						membernamelist.clear();
						for (int i = 0; i < caseDetailEntity.getMembers().size(); i++) {
							membernamelist.add(caseDetailEntity.getMembers().get(i).getName());
						}
						// 发送广播更新动态
						Intent intent = new Intent();
						intent.setAction(Constant.GETDYNAMIC);
						intent.putExtra("caseDetailEntity", caseDetailEntity1);
						sendBroadcast(intent);
						//发送广播上传更新
						Intent intent2 = new Intent();
						intent2.setAction(Constant.GETATTACH);
						intent2.putExtra("caseDetailEntity", caseDetailEntity1);
						sendBroadcast(intent2);
						setData();
						pd.dismiss();
					}

					@Override
					public void onFailed(String Message) {
						ToastHelper.showMsg(CaseDetailActivity.this, "服务端或网络异常！",false);
					}
				});
	}
	
	public String getNum(String str){
		String s;
		if("未处理".equals(str)||"1".equals(str)){
			s = "1";
		}else if("处理中".equals(str)||"2".equals(str)){
			s = "2";
		}else if("已关闭".equals(str)||"3".equals(str)){
			s = "3";
		}else if("等待客户确认".equals(str)||"4".equals(str)){
			s = "4";
		}else if("已完成".equals(str)||"5".equals(str)){
			s = "5";
		}else{
			s = "1";
		}
		return s;
	}

	private void setData() {
		if (caseDetailEntity != null) {
			String title = caseDetailEntity.getTitle();
			String desc = caseDetailEntity.getDesc();
			String creater = caseDetailEntity.getCreater();
			String createtime = caseDetailEntity.getLast_modified();
			String status = caseDetailEntity.getStatus();
			mTv_title.setText("运维申请详情");
			mTv_title2.setText(title);
			tv_desc.setText(desc);
			mTv_creater.setText(creater);
			
			SharedPreferences sp = getSharedPreferences("cgid", 0);
			Editor editor = sp.edit();
			editor.putString(caseid, caseDetailEntity.getGid());
			editor.commit();

			if (status != null && status != "") {

				switch (Integer.valueOf(getNum(status))) {
				case 1:
					tv_casedetail_status.setText("未处理");
					break;
				case 2:
					tv_casedetail_status.setText("处理中");
					break;
				case 3:
					tv_casedetail_status.setText("已关闭");
					break;
				case 4:
					tv_casedetail_status.setText("等待客户确认");
					break;
				case 5:
					tv_casedetail_status.setText("已完成");
					break;
				default:
					break;
				}

			}
			if (createtime != null) {
				String month = createtime.substring(4, 6);
				String day = createtime.substring(6, 8);
				String hours = createtime.substring(8, 10);
				String mins = createtime.substring(10, 12);
				String secs = createtime.substring(12, 14);
				tv_format_create.setText(month + "-" + day + " " + hours + ":"
						+ mins + ":" + secs);
			}
			new Handler().postDelayed(new Runnable() {

				@Override
				public void run() {
					mScrollView.scrollTo(0, 0);
				}
			}, 500);
		}

	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {

		if (mPopupWindow != null) {
			mPopupWindow.dismiss();
			isShowDownDrop = false;
		}

		return super.onTouchEvent(event);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		if (data != null) {
			if (requestCode == Constant.ChangeCaseDetail_Code) {
				if (resultCode == Constant.ChangeCaseDetail_Code) {
//					getCaseDetailInfo();
					getCaseDetailInfo2();
				}
			}
		}

		super.onActivityResult(requestCode, resultCode, data);
	}

	@Override
	protected void onDestroy() {
//		unregisterReceiver(messageReceiver);
//		unregisterReceiver(closeactivyReceiver);
//		unregisterReceiver(uploadfileReceiver);
		super.onDestroy();
	}
	
}
